<template>
  <div class="ivz-options-form">
    <div style="position: relative; margin-bottom: 3px">
      <a-radio-group v-model:value="value" button-style="solid" size="small">
          <a-radio-button value="dict">数据字典</a-radio-button>
          <a-radio-button value="url">url地址</a-radio-button>
      </a-radio-group>
    </div>
    <div v-if="value == 'dict'">
      <a-select v-model:value="model['dictValue']" placeholder="请选择字典类型"
                @change="dictChange" :options="treeData" style="width: 100%" :allowClear="true"/>
    </div>
    <div v-else>
        <a-input v-model:value="model['urlValue']" placeholder="请输入地址(相对地址)" />
    </div>
<!--    <a-modal v-model:visible="visible" title="新增字典" @ok="handleOk">-->
<!--      <p>Some contents...</p>-->
<!--      <p>Some contents...</p>-->
<!--      <p>Some contents...</p>-->
<!--    </a-modal>-->
  </div>
</template>

<script>
  import {ref} from "vue";
  import {BooleanData} from "@/components/OptionsMetaData";

  export default {
    name: "IvzOptionsForm",
    props: ["meta", "model"],
    setup() {
        let value = ref("dict");
        let treeData = ref([
          {label: '测试状态', value: 'test_status'}
        ])
      return {
        value,
        treeData,
        visible: false
      };
    },
    created() {
        if(import.meta.env.PROD) {
          this.$http.get("/lcd/online/dictType").then(resp => {
            if(resp['code'] == 200) {
              this.treeData = resp.data;
            } else {
              this.$msg.warningMessage(resp['message'])
            }
          }).catch(reason => {
            console.warn(`获取字典类型失败[/lcd/online/dictType]将使用默认值`)
          })
        }
    },

    methods: {
      dictChange(val) {
          if(import.meta.env.PROD) {

          } else {
            this.model['options'] = BooleanData
          }
      },
      handleOk() {

      }
    }
  }
</script>

<style scoped>
    .ivz-options-form {
        /*border-bottom: 1px dashed #afafaf;*/
    }
    .ivz-options-form .ant-input {
        padding: 4px 4px;
    }
    .ivz-options-form .ivz-of-item {
        position: relative;
    }
</style>
